package top.lshaci.learning.springboot.web.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.http.CacheControl;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.concurrent.TimeUnit;

@Configuration
public class FileDownloadConfig implements WebMvcConfigurer {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/fileDownload/**")
                .addResourceLocations("file:D:/")
                .setCacheControl(CacheControl.maxAge(365L, TimeUnit.DAYS).cachePublic())
        ;
    }
}
